<?php
/**
 * Created by IntelliJ IDEA.
 * User: keke
 * Date: 18-10-27
 * Time: 下午6:29
 */
//session_start();
//require_once "./lib/common.php";
//require_once "./congfig/config.php";
//$username = $_SESSION['username'];
//$sql = "SELECT * FROM `proinfor` WHERE teacher ='$username'";
//$query = $conn->query($sql);

require_once "../congfig/config.php";
require_once "../lib/common.php";
$realname = $_POST['realname'];
$age = $_POST['age'];
$phone = $_POST['phone'];
if ($realname == null || $age == null || $phone == null) {
    exit(jsoncall(-1, "信息不能空"));
}

$sql = "select realname from userinfor where uid = '$uid'";
$query = $conn->query($sql);
$result = $query->fetch_array();
if ($result['realname'] !== null) {
    exit(jsoncall(-1, "实名无法修改"));
}
$sql = "UPDATE userinfor SET
 null ,`realname`='$realname',`age`='$age',`phone`='$$phone' WHERE uid = '$uid'";
$query = $conn->query($sql);
if ($query) {
    exit(jsoncall(1, "修改信息成功"));
} else {
    exit(jsoncall(-1, "修改信息失败"));
}